﻿using System;

namespace Cms.Domain
{
    public class SourceCodeVersion : ICloneable, IAuditable
    {
        private string _code;
        private Administrator _editedBy;
        private string _timestamp;

        public SourceCodeVersion()
        {
        }
        
        private SourceCodeVersion(SourceCodeVersion original)
        {
            _editedBy = original.EditedBy;
            _code = original.Code;
            _timestamp = original.Timestamp;
        }

        public virtual int ID { get; set; }

        public virtual string Timestamp
        {
            get { return _timestamp; }
            set { _timestamp = value; }
        }

        public virtual string Code
        {
            get { return _code; }
            set { _code = value; }
        }
        
        public virtual Administrator EditedBy
        {
            get { return _editedBy; }
            set { _editedBy = value; }
        }

        public virtual SourceCode Parent { get; set; }

        #region ICloneable Members

        public virtual object Clone()
        {
            return new SourceCodeVersion(this);
        }

        #endregion

        #region IAuditable Members

        public virtual string GetState()
        {
            return "Timestamp = " + _timestamp +
                   ", EditedByID = " + _editedBy.ID +
                   ", Code = " + _code;
        }

        #endregion
    }
}